package com.mymvc.controller.param;

import com.mymvc.controller.vo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Arrays;

/**
 * @author 王俊彪
 * @version 1.0
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/list.do")
    public String list(HttpServletRequest request, HttpServletResponse response,
                     HttpSession session,Model model){
        request.setAttribute("name","jack");
        session.setAttribute("age",18);
        model.addAttribute("gender","male");
        return "userList";
    }

    @GetMapping("/form.do")
    public String form(){
        return "form";
    }

    @PostMapping("/submitBaseType.do")/*提交简单类型*/
    public String submitBaseType(String username,String password){
        System.out.println(username +" , "+password);
        return "success";
    }

    @PostMapping("/submitVO.do")/*提交简单类型*/
    public String submitVO(User user){
        System.out.println(user);
        return "success";
    }
    @PostMapping("/submitVO02.do")/*提交简单类型*/
    public String submitVO02(User user){
        System.out.println(user);
        return "success";
    }

    @PostMapping("/submitArray.do")/*提交简单类型*/
    public String submitArray(String[] hobby){
        System.out.println(Arrays.toString(hobby));
        return "success";
    }
}
